<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<div id="app">
    <template>
        <div style="text-align: center;font-weight: bold">基础信息</div>
        <el-form :model="formData" ref="formData" :rules="rules" label-width="100px" style="margin-top: 1%">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="表名称" prop="tableName">
                        <el-input size="small" v-model="formData.tableName"></el-input>
                    </el-form-item>
                </el-col>

                <el-col :span="11">
                    <el-form-item label="表备注" prop="tableComment">
                        <el-input size="small" v-model="formData.tableComment"></el-input>
                    </el-form-item>
                </el-col>

            </el-row>

            <el-row>
                <el-col :span="12">
                    <el-form-item label="生成模块名" prop="moduleName">
                        <el-input size="small" v-model="formData.moduleName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="11">
                    <el-form-item label="生成包名" prop="packageName">
                        <el-input size="small" v-model="formData.packageName"></el-input>
                    </el-form-item>
                </el-col>


            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="生成功能名" prop="functionName">
                        <el-input size="small" v-model="formData.functionName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="11">
                    <el-form-item label="生成作者" prop="functionAuthor">
                        <el-input size="small" v-model="formData.functionAuthor"></el-input>
                    </el-form-item>
                </el-col>


            </el-row>


            <el-row>
                <el-col :span="12">
                    <el-form-item label="生成类型" prop="menuType">
                        <el-select class="item-choose" style="width: 100%" v-model="formData.genMenuType" size="small"
                                   @change="selectChanged">
                            <el-option
                                    v-for="(item,index) in options"
                                    :key="index"
                                    :label="item.label"
                                    :value="item.value"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>

                <el-col :span="11" v-if="showDirMenu">
                    <el-form-item label="生成目录" prop="menuType">
                        <el-select class="item-choose" style="width: 100%" v-model="formData.genParentMenuId"
                                   size="small">
                            <el-option
                                    v-for="(item,index) in parentMenuList"
                                    :key="index"
                                    :label="item.menuName"
                                    :value="item.id"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>


            </el-row>

        </el-form>
        <div style="text-align: center;margin-top: 5%">
            <el-button size="small" @click="closePage">取 消</el-button>
            <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/gen.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    let id = getQueryString("id");
    new Vue({
        el: '#app',
        data() {
            return {
                formData: {},
                rules: {},
                showDirMenu: false,
                options: [
                    {
                        value: '1',
                        label: '目录'
                    }, {
                        value: '2',
                        label: '菜单'
                    }],
                parentMenuList: [],
                value: '1',
            }
        },
        created() {
            if (id) {
                requests.get('/tool/table/detail/' + id)
                    .then((res) => {
                        if (res.code === '200') {
                            this.formData = res.data
                            if (!res.data.genMenuType) {
                                this.formData.genMenuType = "1"
                            } else {
                                if (res.data.genMenuType === '2') {
                                    this.showDirMenu = true
                                }
                            }
                        }
                    });
            } else {
                this.formData = {}
            }

            requests.get("/sys/menu/getParentMenu").then(res => {
                this.parentMenuList = res.data;
            })

        },
        methods: {
            selectChanged(value) {
                if (value === '2') {
                    this.showDirMenu = true
                } else {
                    this.showDirMenu = false
                }
            },
            handleSubmit() {
                if (id) {
                    addOrUpdate('/tool/table/update', this);
                }
            }
        }
    });
</script>
</html>
